﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(CanvasGroup))]
public class FadeInOnStart : MonoBehaviour {
    public float fadeInTime;
    private CanvasGroup m_Group;
    private float m_Timer;

    private void Awake() {
        m_Group = GetComponent<CanvasGroup>();
        m_Group.alpha = 0;
    }

	// Update is called once per frame
	void Update () {
        m_Group.alpha = Mathf.Lerp(0, 1, m_Timer / fadeInTime);
        m_Timer += Time.deltaTime;
        if(m_Timer > fadeInTime) {
            Destroy(this);
        }
	}
}
